const path = require('path')

function resolve(dir) {
    return path.join(__dirname, dir)//path.join(__dirname)设置绝对路径
}

module.exports = {
    chainWebpack: (config) => {
        //第一个参数：设置的别名，第二个参数：设置的路径
        config.resolve.alias
            .set('@', resolve('./src'))
            .set('components', resolve('./src/components'))
    },
    css: {
        loaderOptions: {
            postcss: {
                plugins: [
                    //把px单位换算成rem单位
                    require("postcss-pxtorem")({
                        rootValue: 75,
                        unitPrecision: 5,
                        propList: ['*'],
                        replace: true,
                        mediaQuery: false,
                        minPixelValue: 0
                    })
                    // require("postcss-pxtorem")({
                    //     rootValue: 37.5,
                    //     propList: ['*'],
                    // })
                ]
            }
        }
    }
}